﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace lab5
{
    public partial class Form1 : Form
    {
        int total = 0;
        public Form1()
        {
            InitializeComponent();
        }
        public abstract class AbstractFlowers
        {
            private string name;
            protected int cost;
            public void SetName(string name)
            {
                this.name = name;
            }
            public string GetName()
            {
                return name;
            }
            public int GetCost()
            {
                return cost;
            }
            public void SetCost(int A)
            {
                cost = A;
            }
        }
        public class Gardenflowers : AbstractFlowers
        {
        }
        public class Gerbera : Gardenflowers
        {
            public Gerbera()
            {
                cost = 80;
            }
        }
        public class Colchicum : Gardenflowers
        {
            public Colchicum()
            {
                cost = 20;
            }
        }
        public class Rose : Gardenflowers
        {
            public Rose()
            {
                cost = 150;
            }
        }
        public class Buket
        {
            public List<AbstractFlowers> flower = new List<AbstractFlowers>();
            public void AddFlower(AbstractFlowers vibor)
            {
                flower.Add(vibor);
            }
        }
        public class Calculator
        {
            public int sum;
            public Calculator() { }
            public int GetTotalCost(Buket vibor)
            {
                foreach (var item in vibor.flower)
                {
                    sum += item.GetCost();
                }
                return sum;
                //Console.WriteLine(sum);
            }
        }
        private void buttonRose_Click(object sender, EventArgs e)
        {
            Rose r = new Rose();
            Buket D = new Buket();
            D.AddFlower(r);
            Calculator G = new Calculator(); 
            textBox1.Text += Environment.NewLine+"Rose add";
            textBox1.Text += Environment.NewLine + "cost=150" + Environment.NewLine;
            total += G.GetTotalCost(D);
        }

        private void buttonGerbera_Click(object sender, EventArgs e)
        {
            Gerbera g = new Gerbera();
            Buket B = new Buket();
            B.AddFlower(g);
            Calculator H = new Calculator(); 
            textBox1.Text += Environment.NewLine + "Gerbera add";
            textBox1.Text += Environment.NewLine + "cost=80" + Environment.NewLine;
            total += H.GetTotalCost(B);
        }

        private void buttonColchicum_Click(object sender, EventArgs e)
        {
            Colchicum c = new Colchicum();
            Buket F = new Buket();
            F.AddFlower(c);
            Calculator C = new Calculator(); 
            textBox1.Text += Environment.NewLine + "Colchicum add";
            textBox1.Text += Environment.NewLine + "cost=20" + Environment.NewLine;
            total += C.GetTotalCost(F);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text += Environment.NewLine + "сумма=" + total;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
        }
    }
}
